//
//  HBGetUserLoanContractParser.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/29.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBGetUserLoanContractParser.h"
#import "HBGetUserLoanContractItemInfo.h"
#import "HBGetUserLoanContractInfo.h"

@implementation HBGetUserLoanContractParser

-(ParserResult*)parseResponseDictionary:(NSDictionary *)responseDictionary
{
    LLog(@"responseDictionary:%@",responseDictionary);
    ParserResult* result=[[ParserResult alloc]init];
    NSNumber* codeObject=[responseDictionary objectForKey:Key_Code];
    if (codeObject)
    {
        NSInteger code = [codeObject integerValue];
        result.code = code;
        result.message = [responseDictionary objectForKey:Key_Msg];
        if (code == 0)
        {
            HBGetUserLoanContractInfo *info = [[HBGetUserLoanContractInfo alloc]init];
            NSArray *dataArray = [responseDictionary objectForKey:Key_Data];
            if (dataArray&&[dataArray isKindOfClass:[NSArray class]])
            {
                NSMutableArray *dataMulArray = [NSMutableArray arrayWithCapacity:dataArray.count];
                for (NSDictionary *dict in dataArray)
                {
                    HBGetUserLoanContractItemInfo *listInfo = [[HBGetUserLoanContractItemInfo alloc]init];
                    listInfo.borrowerName = [DataTypeTranslate stringToString:dict[Key_borrowerName]];
                    listInfo.borrowerCardno = [DataTypeTranslate stringToString:dict[Key_borrowerCardno]];
                    listInfo.loanMoney = [DataTypeTranslate numberToString:dict[Key_loanMoney]];
                    listInfo.loanDate = [DataTypeTranslate numberToString:dict[Key_loanDate]];
                    listInfo.loanPeriod = [DataTypeTranslate numberToString:dict[Key_loanPeriod]];
                    listInfo.expireDate = [DataTypeTranslate numberToString:dict[Key_expireDate]];
                    listInfo.contractUrl = [DataTypeTranslate stringToString:dict[Key_contractUrl]];
                    
                    [dataMulArray addObject:listInfo];
                }
                info.dataAry = dataMulArray;
                result.result = info;
            }
            else
            {
                //                info.dataAry = [NSArray array];
                result.code=1;
                result.message=@"服务器数据异常";
            }
            
            
        }
        
    }
    else
    {
        result.code=1;
        result.message=@"服务器数据异常";
    }
    
    return result;
}

@end
